Skip to content

[py] move information code to files #2093

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 5, 2024
Merged

Conversation

Delta456
Copy link
Member

@Delta456 Delta456 commented Dec 4, 2024

User description

Thanks for contributing to the Selenium site and documentation!
A PR well described will help maintainers to review and merge it quickly

Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, and help reviewers by making them as simple and short as possible.

Description

Moved information code to code files for better navigation.

Motivation and Context

Types of changes

  • Change to the site (I have double-checked the Netlify deployment, and my changes look good)
  • Code example added (and I also added the example to all translated languages)
  • Improved translation
  • Added new translation (and I also added a notice to each document missing translation)

Checklist

  • I have read the contributing document.
  • I have used hugo to render the site/docs locally and I am sure it works.

PR Type

Tests, Documentation


Description

  • Added a new Python test script for Selenium WebDriver to test various element properties.
  • Updated multiple language documentation files to reference the new test script instead of inline code.
  • Improved navigation and consistency by centralizing Python code examples in a dedicated test file.

Changes walkthrough 📝

Relevant files
Tests
test_information.py
Add Selenium WebDriver test script for element properties

examples/python/tests/elements/test_information.py

  • Added a new test script for Selenium WebDriver.
  • Tests various element properties like visibility, enablement,
    selection, tag name, rect, CSS value, text, and attributes.
  • Utilizes pytest for test execution.
  • +45/-0   
    Documentation
    information.en.md
    Update Python code references in documentation                     

    website_and_docs/content/documentation/webdriver/elements/information.en.md

  • Updated Python code examples to reference new test file.
  • Removed inline Python code snippets.
  • +16/-52 
    information.ja.md
    Update Python code references in Japanese documentation   

    website_and_docs/content/documentation/webdriver/elements/information.ja.md

  • Updated Python code examples to reference new test file.
  • Removed inline Python code snippets.
  • +19/-59 
    information.pt-br.md
    Update Python code references in Portuguese documentation

    website_and_docs/content/documentation/webdriver/elements/information.pt-br.md

  • Updated Python code examples to reference new test file.
  • Removed inline Python code snippets.
  • +17/-71 
    information.zh-cn.md
    Update Python code references in Chinese documentation     

    website_and_docs/content/documentation/webdriver/elements/information.zh-cn.md

  • Updated Python code examples to reference new test file.
  • Removed inline Python code snippets.
  • +18/-69 

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Copy link

    netlify bot commented Dec 4, 2024

    👷 Deploy request for selenium-dev pending review.

    Visit the deploys page to approve it

    Name Link
    🔨 Latest commit 2c97203

    Copy link
    Contributor

    qodo-merge-pro bot commented Dec 4, 2024

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Resource Leak
    The WebDriver instance is not properly closed after test execution. Should add a teardown to close the driver.

    Assertion Issue
    Hard-coded assertion values may be brittle and fail if the test page layout changes. Consider making assertions more flexible or using relative values.

    Code Style
    Function name has a typo ('informarion' instead of 'information') which should be fixed for clarity.

    Copy link
    Contributor

    qodo-merge-pro bot commented Dec 4, 2024

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    General
    Ensure browser resources are properly cleaned up after test execution

    Add cleanup by calling driver.quit() after the test to properly close the browser
    and free resources. This prevents browser processes from hanging around.

    examples/python/tests/elements/test_information.py [7-11]

     def test_informarion():
         # Initialize WebDriver
         driver = webdriver.Chrome()
         driver.implicitly_wait(0.5)
    -    ...
    +    try:
    +        ...
    +    finally:
    +        driver.quit()
    Suggestion importance[1-10]: 9

    Why: Adding proper cleanup with driver.quit() is crucial for preventing memory leaks and orphaned browser processes. This is a critical best practice for WebDriver tests.

    9
    Improve test failure debugging by adding descriptive assertion messages

    Add error handling around the assertions to provide more meaningful error messages
    when tests fail.

    examples/python/tests/elements/test_information.py [16-24]

    -assert is_email_visible == True
    -assert is_enabled_button == True
    -assert is_selected_check == True
    +assert is_email_visible == True, "Email input element is not visible"
    +assert is_enabled_button == True, "Button input element is not enabled"
    +assert is_selected_check == True, "Checkbox input element is not selected"
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: Adding descriptive assertion messages significantly improves test debugging by providing clear context when tests fail, reducing time spent investigating failures.

    8
    Fix spelling error in function name to improve code readability

    Fix the typo in the test function name from "informarion" to "information" to
    maintain code clarity and consistency.

    examples/python/tests/elements/test_information.py [7]

    -def test_informarion():
    +def test_information():
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: The typo in the function name ("informarion" instead of "information") affects code readability and maintainability. Fixing it ensures consistent naming throughout the codebase.

    7

    💡 Need additional feedback ? start a PR chat

    Copy link
    Member

    @harsha509 harsha509 left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Thank you @Delta456

    @harsha509
    Copy link
    Member

    Test failures are due to edge issue in here SeleniumHQ/selenium#14851

    @harsha509 harsha509 merged commit f70edb6 into SeleniumHQ:trunk Dec 5, 2024
    7 of 9 checks passed
    selenium-ci added a commit that referenced this pull request Dec 5, 2024
    * [py] move information code to files
    
    * fix close tabs
    
    ---------
    
    Co-authored-by: Sri Harsha <[email protected]> f70edb6
    @Delta456 Delta456 deleted the info_py branch March 19, 2025 10:54
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants